from django.http import JsonResponse
from common.authCheck.adminAuth import getAdminUser


def chiefAdminCheck(func):
    """
    检查总管理员权限
    :param func:
    :return:
    """

    def wrapper(self, request, *args, **kwargs):
        admin_user = getAdminUser(request.session.get('admin'))
        if admin_user.admin_type != '1':
            if admin_user.admin_type != '2':
                return JsonResponse({
                    'status': False,
                    'errMsg': '你没有权限进行操作'
                }, status=401)
        return func(self, request, *args, **kwargs)
    return wrapper
